<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="订单编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderNo">
              <a-input v-model="model.orderNo" placeholder="请输入订单编号" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="任务名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taskName">
              <a-input v-model="model.taskName" placeholder="请输入任务名称" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="商务人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPerson">
              <j-select-user-by-dep v-model="model.businessPerson" />
            </a-form-model-item>
          </a-col>
        </a-row>
          <a-row>
            <a-col :span="8" >
              <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerName">
                <a-input v-model="model.customerName" placeholder="请输入客户名称/联系人" ></a-input>
              </a-form-model-item>
            </a-col>
          <a-col :span="8" >
            <a-form-model-item label="客户电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerPhone">
              <a-input v-model="model.customerPhone" placeholder="请输入客户电话" ></a-input>
            </a-form-model-item>
          </a-col>
            <a-col :span="8" >
              <a-form-model-item label="公司名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyName">
                <a-input v-model="model.companyName" placeholder="请输入公司名称" ></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" >
              <a-form-model-item label="客户税号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerTaxId">
                <a-input v-model="model.customerTaxId" placeholder="请输入客户税号" ></a-input>
              </a-form-model-item>
            </a-col>
          </a-row>
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="下单时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderTime">
              <j-date placeholder="请选择下单时间" v-model="model.orderTime" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="交付时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="requiredDeliveryTime">
              <j-date placeholder="请选择交付时间" v-model="model.requiredDeliveryTime" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="总工期/天" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="totalDays">
              <a-input v-model="model.totalDays" placeholder="请输入总工期/天" disabled></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="模型数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="modelCount">
              <a-input-number v-model="model.modelCount" placeholder="请输入模型数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <!--          <a-col :span="8" >-->
          <!--            <a-form-model-item label="模型克重" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="modelWeight">-->
          <!--              <a-input-number v-model="model.modelWeight" placeholder="请输入模型克重" style="width: 100%" />-->
          <!--            </a-form-model-item>-->
          <!--          </a-col>-->
          <a-col :span="8" >
            <a-form-model-item label="上机克重" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="machineWeight">
              <a-input-number v-model="model.machineWeight" placeholder="请输入上机克重" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="单克金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="quotePerGram">
              <a-input v-model="model.quotePerGram" placeholder="请输入单克金额" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
          <a-row  >
            <a-col :span="8" >
              <a-form-model-item label="预估金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="estimatedAmount">
                <a-input-number v-model="model.estimatedAmount" placeholder="上机克重*单克金额" style="width: 100%" disabled/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" >
              <a-form-model-item label="设计金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designAmount">
                <a-input-number v-model="model.designAmount" placeholder="请输入设计金额" style="width: 100%" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8" >
              <a-form-model-item label="实际金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualAmount">
                <a-input-number v-model="model.actualAmount" placeholder="请输入实际金额" style="width: 100%" />
              </a-form-model-item>
            </a-col>
          </a-row>
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="货款状态" :labelCol="labelCol3" :wrapperCol="wrapperCol3" prop="paymentStatus">
              <j-dict-select-tag type="radio" v-model="model.paymentStatus" dictCode="payment_status" placeholder="请选择货款状态" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="首付款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="downPayment">
              <a-input-number v-model="model.downPayment" placeholder="首付款" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="已收金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receivedAmount">
              <a-input-number v-model="model.receivedAmount" placeholder="已收金额根据财务入账确认为准" style="width: 100%" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="未收金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receivedAmount">
              <a-input-number v-model="model.unpaidAmount" placeholder="未收金额自动计算" style="width: 100%" disabled  />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="单子类型" :labelCol="labelCol3" :wrapperCol="wrapperCol3" prop="orderType">
              <j-dict-select-tag type="radio" v-model="model.orderType" dictCode="order_type" placeholder="请选择单子类型" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
        </a-row>
        <a-row>
          <a-col :span="24" >
            <a-form-model-item label="发货方式" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="deliveryMethod">
              <j-dict-select-tag type="radio" v-model="model.deliveryMethod" dictCode="delivery_method" placeholder="请选择发货方式" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24" >
            <a-form-model-item   label="客户要求" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="customerRequirements">
              <a-textarea v-model="model.customerRequirements" rows="5" placeholder="请输入客户要求" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="订单图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderImages">
              <j-image-upload isMultiple  v-model="model.orderImages" ></j-image-upload>
            </a-form-model-item>
          </a-col>
            <a-col :span="8" >
              <a-form-model-item label="订单模型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderModel">
                <j-upload v-model="model.orderModel"  ></j-upload>
              </a-form-model-item>
            </a-col>
          <a-col :span="8" >
          </a-col>
        </a-row>
<!--          <a-col :span="8" >-->
<!--            <a-form-model-item label="当前状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="currentStatus">-->
<!--              <a-input v-model="model.currentStatus" placeholder="请输入当前状态" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-model-item label="备注" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="remarks">-->
<!--              <a-textarea v-model="model.remarks" rows="4" placeholder="请输入备注" />-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-model-item label="存在问题点" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="issues">-->
<!--              <a-textarea v-model="model.issues" rows="4" placeholder="请输入存在问题点" />-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
          <a-divider style="border-color: #7cb305" dashed orientation="left"><span style="color: #40a9ff;">工作计划表</span></a-divider>
        <a-row>
        <div class="project-schedule">
          <!-- 设计部区域 -->
          <a-row :gutter="[16, 8]" class="department-section">
            <!-- 左侧部门标题（横跨右侧三行） -->
            <a-col
              :xs="24"
              :sm="6"
              :md="4"
              :lg="4"
              :xl="3"
              class="left-column"
            >
              设计部（总工期占比≤30%）
            </a-col>

            <!-- 右侧内容区（三行结构） -->
            <a-col
              :xs="24"
              :sm="18"
              :md="20"
              :lg="20"
              :xl="21"
              class="right-content"
            >
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">设计工期: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item  style="margin-bottom: 0px;" label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designPlannedStart">
                  <j-date placeholder="请选择设计计划开始时间" v-model="model.designPlannedStart" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item  style="margin-bottom: 0px;" label="结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designPlannedEnd">
                  <j-date placeholder="请选择设计计划结束时间" v-model="model.designPlannedEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                </a-form-model-item>
                </a-col>
              </a-row>
<!--              <a-row :gutter="[16, 8]" class="content-row">-->
<!--                <a-col :xs="24" :sm="8" :md="4">设计节点进度跟进: </a-col>-->
<!--                <a-col :xs="24" :sm="8" :md="10" class="signature-col">-->
<!--                  <a-form-model-item  style="margin-bottom: 0px;"  label="进度跟进" :labelCol="labelCol3" :wrapperCol="wrapperCol3" prop="designProgressTracking">-->
<!--                    <a-textarea v-model="model.designProgressTracking" rows="2" placeholder="请输入设计节点进度跟进" />-->
<!--                  </a-form-model-item>-->
<!--                </a-col>-->
<!--              </a-row>-->
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">实际工期/工时: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item  style="margin-bottom: 0px; "label="交付时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designActualEnd">
                    <j-date placeholder="请选择设计实际交付时间" v-model="model.designActualEnd" style="width: 100%"  disabled :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                    <a-form-model-item style="margin-bottom: 0px;"  label="实际工时(小时)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designActualHours">
                      <a-input-number v-model="model.designActualHours" placeholder="请输入设计实际工时(小时)" style="width: 100%" disabled/>
                    </a-form-model-item>
                </a-col>
              </a-row>
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">进度跟进: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item  style="margin-bottom: 0px;" label="" :labelCol="labelCol4" :wrapperCol="wrapperCol4" prop="designProgressTracking">
                    <a-textarea v-model="model.designProgressTracking" rows="1" placeholder="请输入设计节点进度跟进" />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-col>
          </a-row>

          <!-- 商务部区域 -->
          <a-row :gutter="[16, 8]" class="department-section">
            <a-col
              :xs="24"
              :sm="6"
              :md="4"
              :lg="4"
              :xl="3"
              class="left-column"
            >
              商务部（总工期占比≤10%）
            </a-col>
            <a-col
              :xs="24"
              :sm="18"
              :md="20"
              :lg="20"
              :xl="21"
              class="right-content"
            >
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="16" :md="4">商务与客户确认工期:</a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item    style="margin-bottom: 0px;" label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPlannedStart">
                  <j-date placeholder="请选择商务确认计划开始时间" v-model="model.businessPlannedStart" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;"  label="结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPlannedEnd">
                    <j-date placeholder="请选择商务确认计划结束时间" v-model="model.businessPlannedEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>

              </a-row>
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">实际工期/工时: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;" label="确认完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessActualConfirm">
                    <j-date placeholder="请选择商务实际确认完成时间" v-model="model.businessActualConfirm" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;" label="商务实际工时(小时)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessActualHours">
                    <a-input-number v-model="model.businessActualHours" placeholder="请输入商务实际工时(小时)" style="width: 100%" />
                  </a-form-model-item>
                </a-col>
              </a-row>
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">进度跟进: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;" label="" :labelCol="labelCol4" :wrapperCol="wrapperCol4" prop="businessRemarks">
                    <a-textarea v-model="model.businessRemarks" rows="1" placeholder="请输入商务跟进情况" />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-col>
          </a-row>
          <!-- 生产部-编程区域 -->
          <a-row :gutter="[16, 8]" class="department-section">
            <a-col
              :xs="24"
              :sm="6"
              :md="4"
              :lg="4"
              :xl="3"
              class="left-column"
            >
              生产部-编程（总工期占比≤30%）
            </a-col>
            <a-col
              :xs="24"
              :sm="18"
              :md="20"
              :lg="20"
              :xl="21"
              class="right-content"
            >
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="16" :md="4">计划工期:</a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;" label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingPlannedStart">
                    <j-date placeholder="请选择编程计划开始时间" v-model="model.programmingPlannedStart" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item label="结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingPlannedEnd">
                    <j-date placeholder="请选择编程计划结束时间" v-model="model.programmingPlannedEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>

              </a-row>
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">实际工期/工时: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item  style="margin-bottom: 0px;" label="交付时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingActualEnd">
                    <j-date placeholder="请选择编程实际交付时间" v-model="model.programmingActualEnd" style="width: 100%" disabled :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item  style="margin-bottom: 0px;" label="实际工时(小时)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingActualHours">
                    <a-input-number v-model="model.programmingActualHours" placeholder="请输入编程实际工时(小时)" style="width: 100%" disabled/>
                  </a-form-model-item>
                </a-col>
              </a-row>
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">进度跟进: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;" label="" :labelCol="labelCol4" :wrapperCol="wrapperCol4" prop="programmingProgressTracking">
                    <a-textarea v-model="model.programmingProgressTracking" rows="1" placeholder="请输入编程节点进度跟进" />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-col>
          </a-row>
          <!-- 生产部-生产区域 -->
          <a-row :gutter="[16, 8]" class="department-section">
            <a-col
              :xs="24"
              :sm="6"
              :md="4"
              :lg="4"
              :xl="3"
              class="left-column"
            >
              生产部-生产（总工期占比≥30%）
            </a-col>
            <a-col
              :xs="24"
              :sm="18"
              :md="20"
              :lg="20"
              :xl="21"
              class="right-content"
            >
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="16" :md="4">计划工期:</a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;" label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionPlannedStart">
                    <j-date placeholder="请选择生产计划开始时间" v-model="model.productionPlannedStart" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;"  label="结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionPlannedEnd">
                    <j-date placeholder="请选择生产计划结束时间" v-model="model.productionPlannedEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>

              </a-row>
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">实际工期/工时: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item  style="margin-bottom: 0px;" label="交付时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionActualEnd">
                    <j-date placeholder="请选择生产实际交付时间" v-model="model.productionActualEnd" style="width: 100%" disabled :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item style="margin-bottom: 0px;" label="实际工时(小时)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionActualHours">
                    <a-input-number v-model="model.productionActualHours" placeholder="请输入生产实际总工时(小时)" style="width: 100%" disabled />
                  </a-form-model-item>
                </a-col>
              </a-row>
              <a-row :gutter="[16, 8]" class="content-row">
                <a-col :xs="24" :sm="8" :md="4">进度跟进: </a-col>
                <a-col :xs="24" :sm="8" :md="10" class="signature-col">
                  <a-form-model-item  style="margin-bottom: 0px;" label="" :labelCol="labelCol4" :wrapperCol="wrapperCol4" prop="productionProgressTracking">
                    <a-textarea v-model="model.productionProgressTracking" rows="1" placeholder="请输入生产节点进度跟进" />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-col>
          </a-row>
        </div>
        </a-row>
<!--          <a-col :span="8" >
            <a-form-model-item label="设计计划开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designPlannedStart">
              <j-date placeholder="请选择设计计划开始时间" v-model="model.designPlannedStart" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="设计计划结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designPlannedEnd">
              <j-date placeholder="请选择设计计划结束时间" v-model="model.designPlannedEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="设计实际交付时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designActualEnd">
              <j-date placeholder="请选择设计实际交付时间" v-model="model.designActualEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="设计实际工时(小时)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designActualHours">
              <a-input-number v-model="model.designActualHours" placeholder="请输入设计实际工时(小时)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="设计签字" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designSignature">
              <a-input v-model="model.designSignature" placeholder="请输入设计签字" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="设计备注" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="designRemarks">
              <a-textarea v-model="model.designRemarks" rows="4" placeholder="请输入设计备注" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="设计节点进度跟进" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="designProgressTracking">
              <a-textarea v-model="model.designProgressTracking" rows="4" placeholder="请输入设计节点进度跟进" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="商务确认计划开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPlannedStart">
              <j-date placeholder="请选择商务确认计划开始时间" v-model="model.businessPlannedStart" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="商务确认计划结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPlannedEnd">
              <j-date placeholder="请选择商务确认计划结束时间" v-model="model.businessPlannedEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="商务实际确认时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessActualConfirm">
              <j-date placeholder="请选择商务实际确认时间" v-model="model.businessActualConfirm" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="商务实际工时(小时)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessActualHours">
              <a-input-number v-model="model.businessActualHours" placeholder="请输入商务实际工时(小时)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="商务签字" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessSignature">
              <a-input v-model="model.businessSignature" placeholder="请输入商务签字" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="商务备注" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="businessRemarks">
              <a-textarea v-model="model.businessRemarks" rows="4" placeholder="请输入商务备注" />
            </a-form-model-item>
          </a-col>-->
<!--          <a-col :span="8" >
            <a-form-model-item label="编程计划开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingPlannedStart">
              <j-date placeholder="请选择编程计划开始时间" v-model="model.programmingPlannedStart" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="编程计划结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingPlannedEnd">
              <j-date placeholder="请选择编程计划结束时间" v-model="model.programmingPlannedEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="编程实际交付时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingActualEnd">
              <j-date placeholder="请选择编程实际交付时间" v-model="model.programmingActualEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="编程实际工时(小时)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingActualHours">
              <a-input-number v-model="model.programmingActualHours" placeholder="请输入编程实际工时(小时)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="编程签字" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingSignature">
              <a-input v-model="model.programmingSignature" placeholder="请输入编程签字" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="编程备注" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="programmingRemarks">
              <a-textarea v-model="model.programmingRemarks" rows="4" placeholder="请输入编程备注" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="编程节点进度跟进" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="programmingProgressTracking">
              <a-textarea v-model="model.programmingProgressTracking" rows="4" placeholder="请输入编程节点进度跟进" />
            </a-form-model-item>
          </a-col>-->
<!--          <a-col :span="8" >
            <a-form-model-item label="生产计划开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionPlannedStart">
              <j-date placeholder="请选择生产计划开始时间" v-model="model.productionPlannedStart" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="生产计划结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionPlannedEnd">
              <j-date placeholder="请选择生产计划结束时间" v-model="model.productionPlannedEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="生产实际交付时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionActualEnd">
              <j-date placeholder="请选择生产实际交付时间" v-model="model.productionActualEnd" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="生产实际总工时(小时)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionActualHours">
              <a-input-number v-model="model.productionActualHours" placeholder="请输入生产实际总工时(小时)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="生产签字" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionSignature">
              <a-input v-model="model.productionSignature" placeholder="请输入生产签字" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="生产备注" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="productionRemarks">
              <a-textarea v-model="model.productionRemarks" rows="4" placeholder="请输入生产备注" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="生产节点进度跟进" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="productionProgressTracking">
              <a-textarea v-model="model.productionProgressTracking" rows="4" placeholder="请输入生产节点进度跟进" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="设计工期占比(≤30%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="designDurationRatio">
              <a-input-number v-model="model.designDurationRatio" placeholder="请输入设计工期占比(≤30%)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="商务工期占比(≤10%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessDurationRatio">
              <a-input-number v-model="model.businessDurationRatio" placeholder="请输入商务工期占比(≤10%)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="编程工期占比(≤30%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programmingDurationRatio">
              <a-input-number v-model="model.programmingDurationRatio" placeholder="请输入编程工期占比(≤30%)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="生产工期占比(≥30%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionDurationRatio">
              <a-input-number v-model="model.productionDurationRatio" placeholder="请输入生产工期占比(≥30%)" style="width: 100%" />
            </a-form-model-item>
          </a-col>-->
      </a-form-model>
    </j-form-container>
      <!-- 子表单区域 -->
    <a-tabs v-model="activeKey" @change="handleChangeTabs" hidden="">
      <a-tab-pane tab="商务环节" :key="refKeys[0]" :forceRender="true" >
        <j-vxe-table
          keep-source
          :ref="refKeys[0]"
          :loading="yjOrderBusinessTable.loading"
          :columns="yjOrderBusinessTable.columns"
          :dataSource="yjOrderBusinessTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="true"
          />
      </a-tab-pane>
<!--      <a-tab-pane tab="设计环节" :key="refKeys[1]" :forceRender="true">
        <j-vxe-table
          keep-source
          :ref="refKeys[1]"
          :loading="yjOrderDesignTable.loading"
          :columns="yjOrderDesignTable.columns"
          :dataSource="yjOrderDesignTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="true"
          />
      </a-tab-pane>-->
<!--      <a-tab-pane tab="订单入账金额" :key="refKeys[2]" :forceRender="true">
        <j-vxe-table
          keep-source
          :ref="refKeys[2]"
          :loading="yjOrderPaymentTable.loading"
          :columns="yjOrderPaymentTable.columns"
          :dataSource="yjOrderPaymentTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="true"
          />
      </a-tab-pane>-->
<!--      <a-tab-pane tab="编程环节" :key="refKeys[3]" :forceRender="true">
        <j-vxe-table
          keep-source
          :ref="refKeys[3]"
          :loading="yjProgrammingWorkTable.loading"
          :columns="yjProgrammingWorkTable.columns"
          :dataSource="yjProgrammingWorkTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="true"
          />
      </a-tab-pane>-->
<!--      <a-tab-pane tab="生产环节" :key="refKeys[4]" :forceRender="true">
        <j-vxe-table
          keep-source
          :ref="refKeys[4]"
          :loading="yjOrderProductionTable.loading"
          :columns="yjOrderProductionTable.columns"
          :dataSource="yjOrderProductionTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="true"
          />
      </a-tab-pane>-->
    </a-tabs>
    <a-row v-if="showFlowSubmitButton" style="text-align: center;width: 100%;margin-top: 16px;"><a-button icon="check" style="width: 126px" type="primary" @click="handleOk">提 交</a-button></a-row>
  </a-spin>
</template>

<script>

import { getAction, httpAction } from '@/api/manage'
  import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
  import { JVXETypes } from '@/components/jeecg/JVxeTable'
  import {
    getRefPromise,
    VALIDATE_FAILED,
    validateFormModelAndTables
  } from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
  import { validateDuplicateValue } from '@/utils/util'
  import JFormContainer from '@/components/jeecg/JFormContainer'

  export default {
    name: 'YjOrderForm',
    mixins: [JVxeTableModelMixin],
    components: {
      JFormContainer,
    },
    data() {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        labelCol2: {
          xs: { span: 24 },
          sm: { span: 2 },
        },
        wrapperCol2: {
          xs: { span: 24 },
          sm: { span: 18 },
        },
        labelCol3: {
          xs: { span: 24 },
          sm: { span: 4 },
        },
        wrapperCol3: {
          xs: { span: 24 },
          sm: { span: 20},
        },
        labelCol4: {
          xs: { span: 24 },
          sm: { span: 2 },
        },
        wrapperCol4: {
          xs: { span: 24 },
          sm: { span: 22 },
        },
        model:{
         },
        // 新增时子表默认添加几行空数据
        addDefaultRowNum: 1,
        validatorRules: {
           taskName: [
              { required: true, message: '请输入任务名称!'},
           ],
           customerName: [
              { required: true, message: '请输入客户名称!'},
           ],
           customerPhone: [
             { required: true, message: '请输入客户电话!'},
             { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
           ],
           modelCount: [
              { required: true,message: '请输入模型数量'},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           // modelWeight: [
           //    { required: false,message: '请输入上机克重'},
           //    { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           // ],
           machineWeight: [
              { required: true,message: '请输入上机克重'},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           quotePerGram: [
             { required: true,message: '请输入单克金额'},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           estimatedAmount: [
              { required: false},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           actualAmount: [
              { required: true,message: '请输入实际金额'},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           designAmount: [
              { required: false},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           receivedAmount: [
              { required: false},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           orderTime: [
              { required: true, message: '请输入下单时间!'},
           ],
          requiredDeliveryTime:[
              { required: true, message: '请输入交付时间!'},
           ],
           totalDays: [
              { required: false},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           orderType: [
              { required: true, message: '请输入单子类型!'},
           ],
           paymentStatus: [
              { required: true, message: '请输入货款状态!'},
           ],
           deliveryMethod: [
              { required: true, message: '请输入发货方式!'},
           ],
           businessPerson: [
              { required: true, message: '请输入商务人员!'},
           ],
          downPayment: [
              { required: true,message: '请输入首付款'},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
        },
        refKeys: ['yjOrderBusiness'],
        tableKeys:['yjOrderBusiness'],
        activeKey: 'yjOrderBusiness',
        // 商务环节
        yjOrderBusinessTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '流程状态',
              key: 'bpmStatus',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '任务名称',
              key: 'taskName',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单编号',
              key: 'orderNo',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单ID',
              key: 'orderId',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '商务人员',
              key: 'businessPerson',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '商务与客户确认工期开始时间',
              key: 'clientConfirmedStart',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '商务与客户确认工期结束时间',
              key: 'clientConfirmedEnd',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '商务与客户实际确认时间',
              key: 'actualClientConfirmTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '商务实际工时(小时)',
              key: 'actualHours',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '商务备注',
              key: 'businessRemarks',
               type: JVXETypes.textarea,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '商务签字',
              key: 'businessSignature',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        // 设计环节
        yjOrderDesignTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '流程状态',
              key: 'bpmStatus',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '任务名称',
              key: 'taskName',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单编号',
              key: 'orderNo',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单ID',
              key: 'orderId',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '设计工期开始时间',
              key: 'plannedStartTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '设计工期结束时间',
              key: 'plannedEndTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '设计实际开始时间',
              key: 'actualStartTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '设计实际交付时间',
              key: 'actualEndTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '设计实际总工时(小时)',
              key: 'actualHours',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '设计备注',
              key: 'designRemarks',
               type: JVXETypes.textarea,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '设计负责人签字',
              key: 'designerSignature',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '节点进度跟进',
              key: 'progressTracking',
               type: JVXETypes.textarea,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        // 订单入账金额
        yjOrderPaymentTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '流程状态',
              key: 'bpmStatus',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '任务名称',
              key: 'taskName',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单编号',
              key: 'orderNo',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单ID',
              key: 'orderId',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '收款金额（元）',
              key: 'paymentAmount',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '收款时间',
              key: 'paymentTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '收款方式',
              key: 'paymentMethod',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '收款状态',
              key: 'paymentStatus',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '付款方名称',
              key: 'payerName',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '付款方账号',
              key: 'payerAccount',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '收款方账号',
              key: 'receiverAccount',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '交易流水号',
              key: 'transactionNo',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '是否已开发票',
              key: 'invoiceIssued',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '发票号码',
              key: 'invoiceNo',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '开票日期',
              key: 'invoiceDate',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '收款备注',
              key: 'paymentRemarks',
               type: JVXETypes.textarea,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '确认人',
              key: 'confirmedBy',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '确认时间',
              key: 'confirmedTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        // 编程环节
        yjProgrammingWorkTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '流程状态',
              key: 'bpmStatus',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '任务名称',
              key: 'taskName',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单编号',
              key: 'orderNo',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单ID',
              key: 'orderId',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产记录ID',
              key: 'productionId',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '编程及上机打印工期开始时间',
              key: 'plannedStartTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '编程及上机打印工期结束时间',
              key: 'plannedEndTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '编程实际开始时间',
              key: 'actualStartTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '编程及上机实际交付时间',
              key: 'actualEndTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '编程实际工时(小时)',
              key: 'actualHours',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '编程备注',
              key: 'programmingRemarks',
               type: JVXETypes.textarea,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '编程人员',
              key: 'programmingWorker',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        // 生产环节
        yjOrderProductionTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '流程状态',
              key: 'bpmStatus',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '任务名称',
              key: 'taskName',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单编号',
              key: 'orderNo',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '订单ID',
              key: 'orderId',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产计划接单时间',
              key: 'productionReceiveTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产计划交付时间',
              key: 'productionPlannedDeliveryTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产工期/天',
              key: 'productionDays',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产工期开始时间',
              key: 'plannedStartTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产工期结束时间',
              key: 'plannedEndTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产实际开始时间',
              key: 'actualStartTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产实际交付时间',
              key: 'actualEndTime',
              type: JVXETypes.date,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产实际总工时(小时)',
              key: 'totalActualHours',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产备注',
              key: 'productionRemarks',
               type: JVXETypes.textarea,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产负责人签字',
              key: 'productionSignature',
               type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '节点进度跟进',
              key: 'progressTracking',
               type: JVXETypes.textarea,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        url: {
          add: "/erp/yjOrder/add",
          edit: "/erp/yjOrder/edit",
          queryById: "/erp/yjOrder/queryById",
          yjOrderBusiness: {
            list: '/erp/yjOrder/queryYjOrderBusinessByMainId'
          },
          yjOrderDesign: {
            list: '/erp/yjOrder/queryYjOrderDesignByMainId'
          },
          yjOrderPayment: {
            list: '/erp/yjOrder/queryYjOrderPaymentByMainId'
          },
          yjProgrammingWork: {
            list: '/erp/yjOrder/queryYjProgrammingWorkByMainId'
          },
          yjOrderProduction: {
            list: '/erp/yjOrder/queryYjOrderProductionByMainId'
          },
        }
      }
    },
    props: {
      //流程表单data
      formData: {
        type: Object,
        default: ()=>{},
        required: false
      },
      //表单模式：false流程表单 true普通表单
      formBpm: {
        type: Boolean,
        default: false,
        required: false
      },
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    computed: {
      formDisabled(){
        if(this.formBpm===true){
          if(this.formData.disabled===false){
            return false
          }
          return true
        }
        return this.disabled
      },
      showFlowSubmitButton(){
        if(this.formBpm===true){
          if(this.formData.disabled===false){
            return true
          }
        }
        return false
      }
    },
    created () {
      this.$nextTick(() => {
        this.generateOrderNumber();
      });
      //如果是流程中表单，则需要加载流程表单data
      this.showFlowData();
    },
    watch: {
      'model.machineWeight': 'calculateEstimatedAmount',
      'model.modelCount': 'calculateEstimatedAmount',
      'model.quotePerGram': 'calculateEstimatedAmount',
      'model.requiredDeliveryTime': 'calculateTotaDay'
    },
    methods: {
      /**
       * 计算总工期
       */
      calculateTotaDay(){
        const orderTime = new Date(this.model.orderTime);
        const requiredDeliveryTime = new Date(this.model.requiredDeliveryTime);
        if (orderTime && requiredDeliveryTime) {
          const timeDiff = requiredDeliveryTime.getTime() - orderTime.getTime();
          const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
          this.model.totalDays = daysDiff;
        } else {
          this.model.totalDays = 0;
        }

      },
      calculateEstimatedAmount() {
        const weight = parseFloat(this.model.machineWeight) || 0;
        const quantity = parseFloat(this.model.modelCount) || 0;
        const pricePerGram = parseFloat(this.model.quotePerGram) || 0;
        const estimatedAmount = weight * pricePerGram;
        this.model.estimatedAmount = estimatedAmount.toFixed(2); // 保留两位小数
      },
      generateOrderNumber() {
        if(this.model.orderNo==null){
          const now = new Date();
          const year = now.getFullYear();
          const month = String(now.getMonth() + 1).padStart(2, '0');
          const day = String(now.getDate()).padStart(2, '0');
          const hours = String(now.getHours()).padStart(2, '0');
          const minutes = String(now.getMinutes()).padStart(2, '0');
          const seconds = String(now.getSeconds()).padStart(2, '0');
          const randomNum = Math.floor(Math.random() * 100); // 生成0到999之间的随机数
          const orderNo = `SDYJ-${year}${month}${day}${hours}${minutes}${randomNum}`;
          // 赋值给模型并输出日志
          this.model.orderNo = orderNo;
        }
      },
      addBefore(){
        this.yjOrderBusinessTable.dataSource=[]
        this.yjOrderDesignTable.dataSource=[]
        this.yjOrderPaymentTable.dataSource=[]
        this.yjProgrammingWorkTable.dataSource=[]
        this.yjOrderProductionTable.dataSource=[]
      },
      getAllTable() {
        let values = this.tableKeys.map(key => getRefPromise(this, key))
        return Promise.all(values)
      },
      /** 调用完edit()方法之后会自动调用此方法 */
      editAfter() {
        this.$nextTick(() => {
        })
        console.log("正在加载子表数据，参数:")
        // 加载子表数据
        if (this.model.id) {
          let params = { id: this.model.id }
          this.requestSubTableData(this.url.yjOrderBusiness.list, params, this.yjOrderBusinessTable)
          this.requestSubTableData(this.url.yjOrderDesign.list, params, this.yjOrderDesignTable)
          this.requestSubTableData(this.url.yjOrderPayment.list, params, this.yjOrderPaymentTable)
          this.requestSubTableData(this.url.yjProgrammingWork.list, params, this.yjProgrammingWorkTable)
          this.requestSubTableData(this.url.yjOrderProduction.list, params, this.yjOrderProductionTable)
        }
      },
      //校验所有一对一子表表单
        validateSubForm(allValues){
            return new Promise((resolve,reject)=>{
              Promise.all([
              ]).then(() => {
                resolve(allValues)
              }).catch(e => {
                if (e.error === VALIDATE_FAILED) {
                  // 如果有未通过表单验证的子表，就自动跳转到它所在的tab
                  this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
                } else {
                  console.error(e)
                }
              })
            })
        },
      /** 整理成formData */
      classifyIntoFormData(allValues) {
        let main = Object.assign(this.model, allValues.formValue)
        return {
          ...main, // 展开
          yjOrderBusinessList: allValues.tablesValue[0].tableData,
   /*       yjOrderDesignList: allValues.tablesValue[1].tableData,*/
  /*        yjOrderPaymentList: allValues.tablesValue[2].tableData,*/
    /*      yjProgrammingWorkList: allValues.tablesValue[3].tableData,*/
         /* yjOrderProductionList: allValues.tablesValue[4].tableData,*/
        }
      },
      //渲染流程表单数据
      showFlowData(){
        if(this.formBpm === true){
          let params = {id:this.formData.dataId};
          getAction(this.url.queryById,params).then((res)=>{
            if(res.success){
              this.edit (
                res.result
              );
            }
          })
        }
      },
      validateError(msg){
        this.$message.error(msg)
      },
      /** 确定按钮点击事件 */
      handleOk() {
        /** 触发表单验证 */
        this.getAllTable().then(tables => {
          /** 一次性验证主表和所有的次表 */
          return validateFormModelAndTables(this.$refs.form,this.model, tables)
        }).then(allValues => {
          /** 一次性验证一对一的所有子表 */
          return this.validateSubForm(allValues)
        }).then(allValues => {
          if (typeof this.classifyIntoFormData !== 'function') {
            throw this.throwNotFunction('classifyIntoFormData')
          }
          let formData = this.classifyIntoFormData(allValues)
          // 发起请求
          return this.request(formData)
        }).catch(e => {
          if (e.error === VALIDATE_FAILED) {
            // 如果有未通过表单验证的子表，就自动跳转到它所在的tab
            this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
          } else {
            console.error(e)
          }
        })
      },
      /** 发起请求，自动判断是执行新增还是修改操作 */
      request(formData) {
        let url = this.url.add, method = 'post'
        if (this.model.id) {
          url = this.url.edit
          method = 'put'
        }
        this.confirmLoading = true
        console.log("formData===>",formData);
        // 为所有子表列表添加 taskName 和 orderNo 字段
        if (this.model.id) {
          // 商务环节子表
          if (formData.yjOrderBusinessList && formData.yjOrderBusinessList.length > 0) {
            formData.yjOrderBusinessList.forEach(item => {
              item.taskName = this.model.taskName;
              item.orderNo = this.model.orderNo;
            });
          }

          // 设计环节子表
          if (formData.yjOrderDesignList && formData.yjOrderDesignList.length > 0) {
            formData.yjOrderDesignList.forEach(item => {
              item.taskName = this.model.taskName;
              item.orderNo = this.model.orderNo;
            });
          }

          // 订单入账金额子表
          if (formData.yjOrderPaymentList && formData.yjOrderPaymentList.length > 0) {
            formData.yjOrderPaymentList.forEach(item => {
              item.taskName = this.model.taskName;
              item.orderNo = this.model.orderNo;
            });
          }

          // 编程环节子表
          if (formData.yjProgrammingWorkList && formData.yjProgrammingWorkList.length > 0) {
            formData.yjProgrammingWorkList.forEach(item => {
              item.taskName = this.model.taskName;
              item.orderNo = this.model.orderNo;
            });
          }

          // 生产环节子表
          if (formData.yjOrderProductionList && formData.yjOrderProductionList.length > 0) {
            formData.yjOrderProductionList.forEach(item => {
              item.taskName = this.model.taskName;
              item.orderNo = this.model.orderNo;
            });
          }
        }
        httpAction(url, formData, method).then((res) => {
          if (res.success) {
            this.editAfter();
            this.$message.success(res.message)
            this.$emit('ok')
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.confirmLoading = false
        })
      },

    }
  }
</script>

<style scoped>
.project-schedule {
  padding: 20px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  max-width: 1200px;
  margin: 20px auto;
}

.department-section {
  padding: 0;
  margin-bottom: 16px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  display: flex;
  align-items: stretch;
}

.department-section:last-of-type {
  margin-bottom: 0;
}

.left-column {
  /* 核心：强制文字水平+垂直居中 */
  display: flex;
  align-items: center; /* 垂直居中 */
  justify-content: center; /* 水平居中 */
  font-weight: 500;
  padding: 16px 8px;
  background: #fafafa;
  border-right: 1px solid #e8e8e8;
  /* 确保左侧列高度与右侧内容区一致 */
  height: 100%;
  min-height: 220px; /* 最小高度，避免内容过少时左侧过窄 */
  text-align: center; /* 兼容低版本浏览器 */
}

.right-content {
  padding: 16px;
  flex: 1; /* 右侧占满剩余宽度 */
}

.content-row {
  padding: 12px 0; /* 增加行高，让左侧高度更协调 */
  border-bottom: 1px solid #f0f0f0;
}

.content-row:last-of-type {
  border-bottom: none;
}

.signature-col {
  border-left: 1px solid #f0f0f0;
  padding-left: 16px !important;
}

/* 响应式调整 */
@media (max-width: 575px) {
  .department-section {
    flex-direction: column; /* 手机端改为上下布局 */
  }
  .left-column {
    border-right: none;
    border-bottom: 1px solid #e8e8e8;
    min-height: auto; /* 取消最小高度，适应内容 */
  }
  .signature-col {
    border-left: none;
    border-top: 1px solid #f0f0f0;
    padding-left: 0 !important;
    padding-top: 8px !important;
  }
}

@media (min-width: 576px) and (max-width: 991px) {
  .left-column {
    padding-right: 16px;
  }
}

@media (min-width: 992px) {
  .left-column {
    padding-right: 24px;
  }
}


</style>